package com.orange.quickback.system.api.common.result;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;


import java.util.Date;

@Data
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class QBootResult {

    //是否成功
    private boolean success;

    //返回码
    private int code;

    //返回信息
    private String msg;

    //返回数据
    private Object data;
    private Long timezone;

    public static QBootResult build() {
        return build(null);
    }

    public static QBootResult build(Object data) {
        return new QBootResult(true, 20000, "操作成功",data,new Date().getTime());
    }

    public static QBootResult buildFail() {
        return buildFail("操作失败");
    }

    public static QBootResult buildFail(String msg) {
        return buildFail(400, msg);
    }

    public static QBootResult buildFail(Integer code, String msg) {
        return new QBootResult(false, code, msg, null,new Date().getTime());
    }

}